<?php
/**
 * @version $Id: dwoo_plugins.inc.php 4 2009-12-06 17:58:16Z oystein.rg $
 * @licence http://www.opensource.org/licenses/bsd-license.php The BSD License
 * @copyright Upstruct Berlin Oslo
 */

/**
 * @author     Øystein Riiser Gundersen <oystein@upstruct.com>
 * @package    Dwoo Template Adapter
 * @version    $Revision: 4 $
 */
function dwoo_plugin_url(Dwoo $dwoo, array $rest = array()) {
	$name = array_shift($rest);
	return Cobweb::instance()->resolver()->reverse($name, $rest);
}

function dwoo_plugin_cobweb_reverse_url_map() {
	$map = array();
	$reverse = Cobweb::get('__RESOLVER__')->reverseMap();
	foreach ($reverse as $a => $p)
		$map[$a] = preg_replace('/(\()(\?P?<\w+>)(.*?\))/', '$1$3', $p);

	return JSON::encode($map);
	
}